home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kio / uiserver.h < prev   
Encoding:
C/C++ Source or Header  |  2007-01-15  |  12.3 KB  |  431 lines

  1. /* This file is part of the KDE libraries
  2.    Copyright (C) 2000 Matej Koss <koss@miesto.sk>
  3.                       David Faure <faure@kde.org>
  4.  
  5.    This library is free software; you can redistribute it and/or
  6.    modify it under the terms of the GNU Library General Public
  7.    License version 2 as published by the Free Software Foundation.
  8.  
  9.    This library is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.    Library General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU Library General Public License
  15.    along with this library; see the file COPYING.LIB.  If not, write to
  16.    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17.    Boston, MA 02110-1301, USA.
  18. */
  19. #ifndef __kio_uiserver_h__
  20. #define __kio_uiserver_h__
  21.  
  22. #include <qintdict.h>
  23. #include <qdatetime.h>
  24. #include <qtimer.h>
  25.  
  26. #include <dcopobject.h>
  27. #include <kio/global.h>
  28. #include <kio/authinfo.h>
  29. #include <kurl.h>
  30. #include <kmainwindow.h>
  31. #include <kdatastream.h>
  32. #include <klistview.h>
  33. #include <ksslcertdlg.h>
  34.  
  35. class ListProgress;
  36. class KSqueezedTextLabel;
  37. class ProgressItem;
  38. class UIServer;
  39.  
  40. namespace KIO {
  41.   class Job;
  42.   class DefaultProgress;
  43. }
  44.  
  45.  
  46. struct ListProgressColumnConfig
  47. {
  48.    QString title;
  49.    int index;
  50.    int width;
  51.    bool enabled;
  52. };
  53.  
  54. /**
  55. * List view in the UIServer.
  56. * @internal
  57. */
  58. class KIO_EXPORT ListProgress : public KListView {
  59.  
  60.   Q_OBJECT
  61.  
  62. public:
  63.  
  64.   ListProgress (QWidget *parent = 0, const char *name = 0 );
  65.  
  66.   virtual ~ListProgress();
  67.  
  68.   /**
  69.    * Field constants
  70.    */
  71.   enum ListProgressFields {
  72.     TB_OPERATION = 0,
  73.     TB_LOCAL_FILENAME = 1,
  74.     TB_RESUME = 2,
  75.     TB_COUNT = 3,     //lv_count
  76.     TB_PROGRESS = 4,  // lv_progress
  77.     TB_TOTAL = 5,
  78.     TB_SPEED = 6,
  79.     TB_REMAINING_TIME = 7,
  80.     TB_ADDRESS = 8,
  81.     TB_MAX = 9
  82.   };
  83.  
  84.   friend class ProgressItem;
  85.   friend class UIServer;
  86. protected slots:
  87.   void columnWidthChanged(int column);
  88. protected:
  89.  
  90.   void writeSettings();
  91.   void readSettings();
  92.   void applySettings();
  93.   void createColumns();
  94.  
  95.   bool m_showHeader;
  96.   bool m_fixedColumnWidths;
  97.   ListProgressColumnConfig m_lpcc[TB_MAX];
  98.   //hack, alexxx
  99.   KSqueezedTextLabel *m_squeezer;
  100. };
  101.  
  102. /**
  103. * One item in the ListProgress
  104. * @internal
  105. */
  106. class KIO_EXPORT ProgressItem : public QObject, public QListViewItem {
  107.  
  108.   Q_OBJECT
  109.  
  110. public:
  111.   ProgressItem( ListProgress* view, QListViewItem *after, QCString app_id, int job_id,
  112.                 bool showDefault = true );
  113.   ~ProgressItem();
  114.  
  115.   QCString appId() { return m_sAppId; }
  116.   int jobId() { return m_iJobId; }
  117.  
  118.     bool keepOpen() const;
  119.   void finished();
  120.  
  121.   void setVisible( bool visible );
  122.   void setDefaultProgressVisible( bool visible );
  123.   bool isVisible() const { return m_visible; }
  124.  
  125.   void setTotalSize( KIO::filesize_t bytes );
  126.   void setTotalFiles( unsigned long files );
  127.   void setTotalDirs( unsigned long dirs );
  128.  
  129.   void setProcessedSize( KIO::filesize_t size );
  130.   void setProcessedFiles( unsigned long files );
  131.   void setProcessedDirs( unsigned long dirs );
  132.  
  133.   void setPercent( unsigned long percent );
  134.   void setSpeed( unsigned long bytes_per_second );
  135.   void setInfoMessage( const QString & msg );
  136.  
  137.   void setCopying( const KURL& from, const KURL& to );
  138.   void setMoving( const KURL& from, const KURL& to );
  139.   void setDeleting( const KURL& url );
  140.   void setTransferring( const KURL& url );
  141.   void setCreatingDir( const KURL& dir );
  142.   void setStating( const KURL& url );
  143.   void setMounting( const QString & dev, const QString & point );
  144.   void setUnmounting( const QString & point );
  145.  
  146.   void setCanResume( KIO::filesize_t offset );
  147.  
  148.   KIO::filesize_t totalSize() { return m_iTotalSize; }
  149.   unsigned long totalFiles() { return m_iTotalFiles; }
  150.   KIO::filesize_t processedSize() { return m_iProcessedSize; }
  151.   unsigned long processedFiles() { return m_iProcessedFiles; }
  152.   unsigned long speed() { return m_iSpeed; }
  153.   unsigned int remainingSeconds() { return m_remainingSeconds; }
  154.  
  155.   const QString& fullLengthAddress() const {return m_fullLengthAddress;}
  156.   void setText(ListProgress::ListProgressFields field, const QString& text);
  157. public slots:
  158.   void slotShowDefaultProgress();
  159.   void slotToggleDefaultProgress();
  160.  
  161. protected slots:
  162.   void slotCanceled();
  163.  
  164. signals:
  165.   void jobCanceled( ProgressItem* );
  166.  
  167. protected:
  168.   void updateVisibility();
  169.  
  170.   // ids that uniquely identify this progress item
  171.   QCString m_sAppId;
  172.   int m_iJobId;
  173.  
  174.   // whether shown or not (it is hidden if a rename dialog pops up for the same job)
  175.   bool m_visible;
  176.   bool m_defaultProgressVisible;
  177.  
  178.   // parent listview
  179.   ListProgress *listProgress;
  180.  
  181.   // associated default progress dialog
  182.   KIO::DefaultProgress *defaultProgress;
  183.  
  184.   // we store these values for calculation of totals ( for statusbar )
  185.   KIO::filesize_t m_iTotalSize;
  186.   unsigned long m_iTotalFiles;
  187.   KIO::filesize_t m_iProcessedSize;
  188.   unsigned long m_iProcessedFiles;
  189.   unsigned long m_iSpeed;
  190.   int m_remainingSeconds;
  191.   QTimer m_showTimer;
  192.   QString m_fullLengthAddress;
  193. };
  194.  
  195. class QResizeEvent;
  196. class QHideEvent;
  197. class QShowEvent;
  198. class ProgressConfigDialog;
  199. class QPopupMenu;
  200. class UIServerSystemTray;
  201.  
  202. /**
  203.  * It's purpose is to show progress of IO operations.
  204.  * There is only one instance of this window for all jobs.
  205.  *
  206.  * All IO operations ( jobs ) are displayed in this window, one line per operation.
  207.  * User can cancel operations with Cancel button on toolbar.
  208.  *
  209.  * Double clicking an item in the list opens a small download window ( DefaultProgress ).
  210.  *
  211.  * @short Graphical server for progress information with an optional all-in-one progress window.
  212.  * @author David Faure <faure@kde.org>
  213.  * @author Matej Koss <koss@miesto.sk>
  214.  *
  215.  * @internal
  216.  */
  217. class KIO_EXPORT UIServer : public KMainWindow, public DCOPObject {
  218.  
  219.   K_DCOP
  220.   Q_OBJECT
  221.  
  222.   UIServer();
  223.   virtual ~UIServer();
  224.  
  225. public:
  226.    static UIServer* createInstance();
  227.  
  228. k_dcop:
  229.  
  230.   /**
  231.    * Signal a new job
  232.    * @param appId the DCOP application id of the job's parent application
  233.    * @see KIO::Observer::newJob
  234.    * @param showProgress whether to popup the progress for the job.
  235.    *   Usually true, but may be false when we use kio_uiserver for
  236.    *   other things, like SSL dialogs.
  237.    * @return the job id
  238.    */
  239.   int newJob( QCString appId, bool showProgress );
  240.  
  241.   ASYNC jobFinished( int id );
  242.  
  243.   ASYNC totalSize( int id, unsigned long size );
  244.   ASYNC totalSize64( int id, KIO::filesize_t size );
  245.   ASYNC totalFiles( int id, unsigned long files );
  246.   ASYNC totalDirs( int id, unsigned long dirs );
  247.  
  248.   ASYNC processedSize( int id, unsigned long bytes );
  249.   ASYNC processedSize64( int id, KIO::filesize_t bytes );
  250.   ASYNC processedFiles( int id, unsigned long files );
  251.   ASYNC processedDirs( int id, unsigned long dirs );
  252.  
  253.   ASYNC percent( int id, unsigned long ipercent );
  254.   ASYNC speed( int id, unsigned long bytes_per_second );
  255.   ASYNC infoMessage( int id, const QString & msg );
  256.  
  257.   ASYNC copying( int id, KURL from, KURL to );
  258.   ASYNC moving( int id, KURL from, KURL to );
  259.   ASYNC deleting( int id, KURL url );
  260.   ASYNC transferring( int id, KURL url );
  261.   ASYNC creatingDir( int id, KURL dir );
  262.   ASYNC stating( int id, KURL url );
  263.  
  264.   ASYNC mounting( int id, QString dev, QString point );
  265.   ASYNC unmounting( int id, QString point );
  266.  
  267.   ASYNC canResume( int id, unsigned long offset );
  268.   ASYNC canResume64( int id, KIO::filesize_t offset );
  269.  
  270.   /**
  271.    * @deprecated (it blocks other apps).
  272.    * Use KIO::PasswordDialog::getNameAndPassword instead.
  273.    * To be removed in KDE 4.0.
  274.    */
  275.   QByteArray openPassDlg( const KIO::AuthInfo &info );
  276.  
  277.   /**
  278.    * Popup a message box.
  279.    * @param id The message identifier.
  280.    * @param type type of message box: QuestionYesNo, WarningYesNo, WarningContinueCancel...
  281.    *   This enum is defined in slavebase.h, it currently is:
  282.    *   QuestionYesNo = 1, WarningYesNo = 2, WarningContinueCancel = 3,
  283.    *   WarningYesNoCancel = 4, Information = 5, SSLMessageBox = 6
  284.    * @param text Message string. May contain newlines.
  285.    * @param caption Message box title.
  286.    * @param buttonYes The text for the first button.
  287.    *                  The default is i18n("&Yes").
  288.    * @param buttonNo  The text for the second button.
  289.    *                  The default is i18n("&No").
  290.    * Note: for ContinueCancel, buttonYes is the continue button and buttonNo is unused.
  291.    *       and for Information, none is used.
  292.    * @return a button code, as defined in KMessageBox, or 0 on communication error.
  293.    */
  294.   int messageBox( int id, int type, const QString &text, const QString &caption,
  295.                   const QString &buttonYes, const QString &buttonNo );
  296.  
  297.   /**
  298.    * @deprecated (it blocks other apps).
  299.    * Use KIO::open_RenameDlg instead.
  300.    * To be removed in KDE 4.0.
  301.    */
  302.   QByteArray open_RenameDlg64( int id,
  303.                              const QString & caption,
  304.                              const QString& src, const QString & dest,
  305.                              int /* KIO::RenameDlg_Mode */ mode,
  306.                              KIO::filesize_t sizeSrc,
  307.                              KIO::filesize_t sizeDest,
  308.                              unsigned long /* time_t */ ctimeSrc,
  309.                              unsigned long /* time_t */ ctimeDest,
  310.                              unsigned long /* time_t */ mtimeSrc,
  311.                              unsigned long /* time_t */ mtimeDest
  312.                              );
  313.   /**
  314.    * @deprecated (it blocks other apps).
  315.    * Use KIO::open_RenameDlg instead.
  316.    * To be removed in KDE 4.0.
  317.    */
  318.   QByteArray open_RenameDlg( int id,
  319.                              const QString & caption,
  320.                              const QString& src, const QString & dest,
  321.                              int /* KIO::RenameDlg_Mode */ mode,
  322.                              unsigned long sizeSrc,
  323.                              unsigned long sizeDest,
  324.                              unsigned long /* time_t */ ctimeSrc,
  325.                              unsigned long /* time_t */ ctimeDest,
  326.                              unsigned long /* time_t */ mtimeSrc,
  327.                              unsigned long /* time_t */ mtimeDest
  328.                              );
  329.  
  330.   /**
  331.    * @deprecated (it blocks other apps).
  332.    * Use KIO::open_SkipDlg instead.
  333.    * To be removed in KDE 4.0.
  334.    */
  335.   int open_SkipDlg( int id,
  336.                     int /*bool*/ multi,
  337.                     const QString & error_text );
  338.  
  339.   /**
  340.    * Switch to or from list mode - called by the kcontrol module
  341.    */
  342.   void setListMode( bool list );
  343.  
  344.   /**
  345.    * Hide or show a job. Typically, we hide a job while a "skip" or "rename" dialog
  346.    * is being shown for this job. This prevents killing it from the uiserver.
  347.    */
  348.   void setJobVisible( int id, bool visible );
  349.  
  350.   /**
  351.    * Show a SSL Information Dialog
  352.    */
  353.   void showSSLInfoDialog(const QString &url, const KIO::MetaData &data, int mainwindow);
  354.  
  355.   /**
  356.    * @deprecated
  357.    */
  358.   void showSSLInfoDialog(const QString &url, const KIO::MetaData &data);
  359.  
  360.   /*
  361.    * Show an SSL Certificate Selection Dialog
  362.    */
  363.   KSSLCertDlgRet showSSLCertDialog(const QString& host, const QStringList& certList, int mainwindow);
  364.  
  365.   /*
  366.    * @deprecated
  367.    */
  368.   KSSLCertDlgRet showSSLCertDialog(const QString& host, const QStringList& certList);
  369.  
  370. public slots:
  371.   void slotConfigure();
  372.   void slotRemoveSystemTrayIcon();
  373. protected slots:
  374.  
  375.   void slotUpdate();
  376.   void slotQuit();
  377.  
  378.   void slotCancelCurrent();
  379.  
  380.   void slotToggleDefaultProgress( QListViewItem * );
  381.   void slotSelection();
  382.  
  383.   void slotJobCanceled( ProgressItem * );
  384.   void slotApplyConfig();
  385.   void slotShowContextMenu(KListView*, QListViewItem *item, const QPoint& pos);
  386.  
  387. protected:
  388.  
  389.   ProgressItem* findItem( int id );
  390.  
  391.   virtual void resizeEvent(QResizeEvent* e);
  392.   virtual bool queryClose();
  393.  
  394.   void setItemVisible( ProgressItem * item, bool visible );
  395.  
  396.   QTimer* updateTimer;
  397.   ListProgress* listProgress;
  398.  
  399.   KToolBar::BarPosition toolbarPos;
  400.   QString properties;
  401.  
  402.   void applySettings();
  403.   void readSettings();
  404.   void writeSettings();
  405. private:
  406.  
  407.   void killJob( QCString observerAppId, int progressId );
  408.  
  409.   int m_initWidth;
  410.   int m_initHeight;
  411.   int m_idCancelItem;
  412.   bool m_bShowList;
  413.   bool m_showStatusBar;
  414.   bool m_showToolBar;
  415.   bool m_keepListOpen;
  416.   bool m_showSystemTray;
  417.   bool m_shuttingDown;
  418.  
  419.   // true if there's a new job that hasn't been shown yet.
  420.   bool m_bUpdateNewJob;
  421.   ProgressConfigDialog *m_configDialog;
  422.   QPopupMenu* m_contextMenu;
  423.   UIServerSystemTray *m_systemTray;
  424.  
  425.   static int s_jobId;
  426.   friend class no_bogus_warning_from_gcc;
  427. };
  428.  
  429. // -*- mode: c++; c-basic-offset: 2 -*-
  430. #endif
  431.